﻿import 'package:test_app/core/base/base/base_logic.dart';
import 'package:test_app/weigets/refreshable_list/index.dart';
import 'scroll_list_state.dart';

class Item {
  final int id;

  Item({ required this.id });
}

class ScrollListController extends BaseLogic {

  final ScrollListState textState = ScrollListState();
  final RefreshableListController refreshController = RefreshableListController();

  @override
  void initData() {
    super.initData();
    init();
  }

  void init() {

  }

  Future<void> refreshList() async {
    await refreshController.refresh();
  }

  Future<ListResponse<Item>> fetchData(int pageCount, int pageSize) async {
    await Future.delayed(const Duration(milliseconds: 1000));

    final List<Item> data = [];

    for (int i = 0; i < pageSize; i++) {
      final index = (pageCount - 1) * pageSize + i;
      if (index >= 50) break;
      data.add(Item(id: index));
    }
    return ListResponse<Item>(total: 50, data: data);

  }

}
